package com.bdqn.mapper;

import com.bdqn.ConfigManager;

import java.sql.Connection;
import java.sql.DriverManager;

public class BaseDao {
    /**
     * 返回数据数据库连接
     */
    public static Connection getConnection() {
        Connection connection = null;

        String driver = ConfigManager.getInstance().getValue("jdbc.driver");
        String url = ConfigManager.getInstance().getValue("jdbc.url");
        String username = ConfigManager.getInstance().getValue("jdbc.username");
        String password = ConfigManager.getInstance().getValue("jdbc.password");

        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url, username, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }
}